package com.zhl.service.impl;

import com.zhl.dao.UserDao;
import com.zhl.model.User;
import com.zhl.service.UserService;
import com.zhl.utils.page.PageEntity;
import com.zhl.utils.page.PageUtil;

import java.util.List;
import java.util.Map;

public class UserServiceImpl implements UserService {

    UserDao userDao = new UserDao();

    @Override
    public User findUserByName(String username) {
        return userDao.FindUserByName(username);
    }

    @Override
    public PageEntity<Map<String, Object>> findAll(String realName, Integer id,Integer currPage) {

        PageEntity<Map<String, Object>> pageEntity = new PageEntity<>();
        List<Map<String, Object>> data = userDao.FindAllUser(realName, id, (currPage - 1) * pageEntity.getPageSize(), pageEntity.getPageSize());
        Integer totalCount = userDao.findAll();

        return PageUtil.getPageEntity(pageEntity, currPage, data, totalCount);
    }

    @Override
    public boolean saveUser(User user) {
        return userDao.Save(user);
    }

    @Override
    public Map<String, Object> findUserAndDeptById(Integer id) {
        return userDao.findUserAndDeptById(id);
    }

    @Override
    public Map<String, Object> findUserInfo(Integer id) {
        return userDao.findUserInfoById(id);
    }

    @Override
    public void updateUser(User user,Integer id) {
        userDao.UpdateById(user,id);
    }

    @Override
    public User findUserById(Integer id) {
        return userDao.findById(id);
    }

    @Override
    public boolean updateLookById(Integer id) {
        return userDao.UpdateById(id);
    }

    @Override
    public List<Integer> findUserCollectById(Integer id) {
        return userDao.findCollectById(id);
    }

    @Override
    public List<User> findFocusFavoriteById(Integer uId, Integer aId) {
        return userDao.findFocusFavoriteById(uId,aId);
    }

    @Override
    public List<User> findUserByDeptId(Integer deptId) {
        return userDao.findUserByDeptId(deptId);
    }

    @Override
    public List<Map<String, Object>> findFocus(Integer id) {
        return userDao.findFocusById(id);
    }


}
